﻿@using System.Web.UI.WebControls
@using DevExpress.Web.ASPxEditors
@using DevExpress.Web.Mvc
@using DevExpress.Web.Mvc.UI
@using Dogshow.Model
@model Izlozba
           
<div id="left">

    @using (Ajax.BeginForm("SacuvajOsnovnePodatkeOIzlozbi", "Izlozbe", new AjaxOptions { HttpMethod= "POST", OnSuccess = "onSacuvaniOsnovniPodaci"}, new{@class = "edit_form", style="width:400px;"}))
    {
                @Html.HiddenFor(x => x.Id)
                <div class="line">
                    @Html.HiddenFor(x => x.IdOrganizatora)
                    @Html.DevExpress().Label(label =>
               {
                   label.Text = "Organizator:";
                   label.ControlStyle.CssClass = "label";
                   label.AssociatedControlName = "Organizator";
               }).GetHtml()

                    @Html.DevExpress().Label(label =>
               {
                   label.ControlStyle.CssClass = "editor";
                   label.Name = "Organizator";
               }).Bind(Model.Organizator).GetHtml()
      
      
                </div>
                <div class="line">
                    @Html.DevExpress().Label(label =>
               {
                   label.Text = "Naziv izložbe:";
                   label.ControlStyle.CssClass = "label";
                   label.AssociatedControlName = "NazivIzlozbe";
               }).GetHtml()
            
                    @Html.DevExpress().TextBox(textEdit =>
               {
                   textEdit.Name = "NazivIzlozbe";
                   textEdit.Properties.ConvertEmptyStringToNull = true;
                   textEdit.ShowModelErrors = true;
                   textEdit.ControlStyle.CssClass = "editor";
               }).Bind(Model.NazivIzlozbe).GetHtml()
                </div>
            <div class="line">
                
                @Html.DevExpress().Label(label =>
           {
               label.Text = "Opis:";
               label.ControlStyle.CssClass = "label";
               label.AssociatedControlName = "Opis";
           }).GetHtml()

                @Html.DevExpress().Memo(textEdit =>
           {
               textEdit.Name = "Opis";
               textEdit.Properties.ConvertEmptyStringToNull = true;
               textEdit.ShowModelErrors = true;
               textEdit.ControlStyle.CssClass = "editor";
           }).Bind(Model.Opis).GetHtml()
      
            </div>
            <div class="line">
                
                @Html.DevExpress().Label(label =>
           {
               label.Text = "Datum:";
               label.ControlStyle.CssClass = "label";
               label.AssociatedControlName = "Datum";
           }).GetHtml()
                @Html.DevExpress().DateEdit(date =>
           {
               date.Name = "Datum";
               date.ShowModelErrors = true;
               date.ControlStyle.CssClass = "editor";

           }).Bind(Model.Datum).GetHtml()
      
            </div>
            <div class="line">
                
               @Html.DevExpress().Label(label =>
          {
              label.Text = "Rok prijave:";
              label.ControlStyle.CssClass = "label";
              label.AssociatedControlName = "RokPrijave";
          }).GetHtml()
               @Html.DevExpress().DateEdit(date =>
          {
              date.Name = "RokPrijave";
              date.ShowModelErrors = true;
              date.ControlStyle.CssClass = "editor";

          }).Bind(Model.RokPrijave).GetHtml()
      
            </div>
            <div class="line">
                
                @Html.DevExpress().Label(label =>
           {
               label.Text = "Program izložbe:";
               label.ControlStyle.CssClass = "label";
               label.AssociatedControlName = "ProgramIzlozbe";
           }).GetHtml()
                @Html.DevExpress().Memo(textEdit =>
           {
               textEdit.Name = "ProgramIzlozbe";
               textEdit.Properties.ConvertEmptyStringToNull = true;
               textEdit.ShowModelErrors = true;
               textEdit.ControlStyle.CssClass = "editor";
           }).Bind(Model.ProgramIzlozbe).GetHtml()
      
            </div>
            <div class="line">
                
                @Html.DevExpress().Label(label =>
           {
               label.Text = "Titule i nagrade:";
               label.ControlStyle.CssClass = "label";
               label.AssociatedControlName = "cblTitule";
           }).GetHtml()

                @Html.DevExpress().CheckBoxList((CheckBoxListSettings)ViewBag.CheckBoxSettings).GetHtml()
      
            </div>
            <div class="line">
                
                @Html.DevExpress().Label(label =>
           {
               label.Text = "Završena:";
               label.ControlStyle.CssClass = "label";
               label.AssociatedControlName = "Zavrsena";
           }).GetHtml()
                @Html.DevExpress().CheckBox(cb =>
           {
               cb.Name = "Zavrsena";
               cb.ControlStyle.CssClass = "editor";
           }).Bind(Model.Zavrsena).GetHtml()
      
            </div>
        
        @Html.HiddenFor(x => x.Latituda)
        @Html.HiddenFor(x => x.Longituda)
        
        <div class="line">
            
           @Html.DevExpress().Button(s =>
      {
          s.Name = "btnSacuvajOsnovnePodatke";
          s.Text = "Sačuvaj";
          s.ControlStyle.CssClass = "btnSave";
          //s.ClientSideEvents.Click = "onClick";
          s.UseSubmitBehavior = true;
      }).GetHtml()
      
        </div>
    }
</div>

<div id="map">
</div>

<style>
#left 
{
    float: left;
    width: 395px;
}
#map 
{
    margin-left: 400px;
    width: 310px;
    height: 404px;
}
#Organizator 
{
    font-weight: bold;
}
</style>

<script type="text/javascript">
    var added = false;
    $('#map').gmap().bind('init', function (event, map) {
        $(map).click(function (e) {
            if (added) return;
            added = true;
            $("#Latituda").val(e.latLng.lat());
            $("#Longituda").val(e.latLng.lng());
            $('#map').gmap('addMarker', {
                'position': e.latLng,
                'draggable': true,
                'bounds': true
            }).dragend(doDrag);
        });

        var latituda = parseFloat($("#Latituda").val().replace(',', '.'));
        var longituda = parseFloat($("#Longituda").val().replace(',', '.'));
        if (!isNaN(latituda) && !isNaN(longituda)) {
            var latLng = new google.maps.LatLng(latituda, longituda);
            added = true;
            $("#map").gmap('option', 'center', latLng).gmap('addMarker', {
                'position': latLng,
                'draggable': true,
                'bounds': true
            }).dragend(doDrag);
        }
    });

    function doDrag(e) {
        $("#Latituda").val(e.latLng.lat());
        $("#Longituda").val(e.latLng.lng());
    }
    
    function onSacuvaniOsnovniPodaci() {
        
    }
    
</script>